package cn.gok.servlet;

/**
 * @Author: chenfan
 * @Date: 2020/12/6 13:13
 * @Description: http协议工具类，主要提供响应信息
 */
public class HttpProtocolUtil {

    public static String getHttpHeader200(long contentLength){
        return  "HTTP/1.1 200 OK \n" +
                "Content-Type: text/html \n"+
                "Content-Length: " + contentLength + "\n" +
                "\r\n";
    }

    public static String getHttpHeader404(){
        String str = "<h1> 404 not found</h1>";
        return  "HTTP/1.1 404 NOT Found \n" +
                "Content-Type: text/html \n"+
                "Content-Length: " + str.getBytes().length + "\n" +
                "\r\n" + str;
    }
}
